<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.lmpop.trade.ti_keyword.*"%>
<%@page import="com.lmpop.createIndex.search.*"%>
<%@page import="com.lmpop.frame.util.Config"%>
<%@page import="com.lmpop.frame.util.PageUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>品牌直销-雷鸣商城</title>
<link href="/templets/html/shop/css/style.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/prolistnew.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/templets/html/shop/js/jquery_002.js"></script>
<script type="text/javascript" src="/templets/html/shop/js/prolistnew.js"></script>
	<script type='text/javascript' src='/dwr/engine.js'></script>
		<script type='text/javascript' src='/dwr/util.js'></script>
		<script type='text/javascript' src='/dwr/interface/Ti_subscribeInfo.js'></script> 
		<script type='text/javascript' src='/templets/html/shop/js/_shop.js'></script>
</head>
<body>
<script> 
  document.write("<s" + "cript type='text/javascript' src='/templets/html/shop/top.jsp?" + Math.random() + "'></scr" + "ipt>");
</script>
<%
	request.setCharacterEncoding("UTF-8");

	GoodsIndexFiles goodsIndex = new GoodsIndexFiles();
	CategoryIndexFiles catIndex = new CategoryIndexFiles();
	AttachIndexFiles attachIndex = new AttachIndexFiles();
	BrandIndexFiles brandIndex = new BrandIndexFiles();
	CategoryattrIndexFiles catattrIndex = new CategoryattrIndexFiles();

	Config configa = new Config();
	configa.init();
	String rootpath = configa.getString("rootpath");
	String goods_article_path = configa.getString("goods_article_path");
	String noimg_path = configa.getString("noimg_path");

	String keyword = "",cat_attr="", keyword_b = "", cat_id_para = "", brand_id_para = "",info_state="", orderby = "in_date", sort_type = "true";
	String start_price_para = "", end_price_para = "", attr_desc_para = "";
	if (request.getParameter("keyword") != null) {
		keyword_b = request.getParameter("q");
		keyword = java.net.URLDecoder.decode(keyword_b, "UTF-8");
	}
	if(!keyword.equals("")){
		Ti_keywordInfo keywordInfo = new Ti_keywordInfo();
		String key_type = "0";
		Hashtable keywordMap = new Hashtable();
		keywordMap.put("key_word",keyword);
	    keywordMap.put("key_type",key_type);
		keywordInfo.updateKeyWordNum(keywordMap);
	}
	if (request.getParameter("info_state") != null) {
		info_state = request.getParameter("info_state");
	}
	if (request.getParameter("cat_id_para") != null) {
		cat_id_para = request.getParameter("cat_id_para");
	}
	if (request.getParameter("cat_attr") != null) {
		cat_attr = request.getParameter("cat_attr");
		cat_id_para=cat_attr.substring(cat_attr.length()-16,cat_attr.length()-1);
	}
	
	if (request.getParameter("brand_id_para") != null) {
		brand_id_para = request.getParameter("brand_id_para");
	}
	if (request.getParameter("orderby_para") != null) {
		orderby = request.getParameter("orderby_para");
	}
	if (request.getParameter("sort_type") != null) {
		sort_type = request.getParameter("sort_type");
	}
	String listOrImg = "1";
	if (request.getParameter("listOrImg") != null) {
		listOrImg = request.getParameter("listOrImg");
	}
	String com_page = "/shop_goodslist.html";
	if (request.getParameter("req_url") != null) {
		com_page = request.getParameter("req_url");
	}
	
	String cat_desc = goodsIndex.dealAttrdesc(attr_desc_para);

	Map comMap = new Hashtable();
	comMap.put("keyword", keyword);
	comMap.put("cat_id", cat_id_para);
	comMap.put("brand_id", brand_id_para);
	comMap.put("orderby", orderby);
	comMap.put("sort_type", sort_type);
	comMap.put("info_state", info_state);
	
	List goodsList = goodsIndex.getGoodsInfo(comMap);
	Map gooMap = new Hashtable();
	comMap.put("orderby", "in_date");
	comMap.put("sort_type", "false");
	gooMap.put("cat_id", cat_id_para);
	gooMap.put("brand_id", brand_id_para);
	List hotgoodsList = goodsIndex.getGoodsInfo(gooMap);
	List catNumList=null;
	int cat_size =0;
	catNumList = goodsIndex.getGoodsCatListNum(cat_id_para,goodsList);
	if(catNumList!=null&catNumList.size()>0){
	 	cat_size=catNumList.size();
	 }else{
		cat_id_para="";
		brand_id_para="";
		start_price_para="";
		end_price_para="";
		catNumList = goodsIndex.getGoodsCatListNum(cat_id_para,goodsIndex.getGoodsInfo(new Hashtable()));
		if(catNumList!=null&catNumList.size()>0){
	 		cat_size=catNumList.size();
		 }
	 }
	
	Map bbMap = comMap;
	bbMap.remove("brand_id");
	List brandNumList =null;
	List list_temp=goodsIndex.getGoodsInfo(bbMap);
	if(list_temp!=null&&list_temp.size()>0)
		brandNumList = brandIndex.getGoodsBrandListNum("",list_temp);
	int brandSize=0;
	if(brandNumList!=null&&brandNumList.size()>0)
		brandSize=brandNumList.size();
	
	String a_class=" background: none repeat scroll 0 0 #CC3300;color: #FFFFFF;";
	String page_class="background: none repeat scroll 0 0 #FF9933;border: 1px solid #FF9933;color: #FFFFFF;";
	

	String cat_name_para = catIndex.getCatNameById(cat_id_para);
	String brand_name_para = brandIndex.getBrandNameById(brand_id_para);
	
	List sonCatNumList=null;
%>

<div id="contaner">
  <div class="ShoesList">
    <div class="areaSide">
      <div class="sorttitle">商品分类</div>
      <div class="sort">
      	<%if (catNumList != null && catNumList.size() > 0) {
					Hashtable nMap = new Hashtable();
						for (int i = 0; i < catNumList.size(); i++) {
							nMap = (Hashtable) catNumList.get(i);
							String cat_id = "", cat_name = "", cat_num = "";
							if (nMap.get("cat_id") != null){
								cat_id = nMap.get("cat_id").toString();
							}
							if (nMap.get("cat_name") != null)
								cat_name = nMap.get("cat_name").toString();
							if (nMap.get("cat_num") != null)
								cat_num = nMap.get("cat_num").toString();
							
				%>
				
					        <%
					        	if(cat_id_para.equals("cat_id")){%>
					        		<h2><a href="javascript:updateCatIdBySearch('cat_id_para','<%=cat_id %>');" class="open"></a><%=cat_name%></h2>
									<ul style='display: block;'>
								<%}else if(i==0){%>
									<h2><a href="javascript:updateCatIdBySearch('cat_id_para','<%=cat_id %>');" class="open"></a><%=cat_name%></h2>
					        		<ul style='display: block;'>
					        	<%}else{%>
					        		<h2><a href="javascript:updateCatIdBySearch('cat_id_para','<%=cat_id %>');" ></a><%=cat_name%></h2>
					        		<ul class="hide">
					        	
					        	<%}
					         %>
					          <li class="allshoes current"><strong>所有<a href="javascript:updateCatIdBySearch('cat_id_para','<%=cat_id %>');"><%=cat_name%></a></strong></li>

				 	<%
					       		sonCatNumList=catIndex.getCategoryByUpCatId(cat_id,"2");
					       		Map mMap=null;
					       		if(sonCatNumList!=null&&sonCatNumList.size()>0){
					       			String son_cat_id="",son_cat_name="";
					       			for(int j=0;j<sonCatNumList.size();j++){
					       				mMap = (Hashtable) sonCatNumList.get(j);
					       				if (mMap.get("cat_id") != null){
					       					son_cat_id = mMap.get("cat_id").toString();
					       				}
											
										if (mMap.get("cat_name") != null)
											son_cat_name = mMap.get("cat_name").toString();%>
					       				<li><a class="type" href="javascript:updateCatIdBySearch('cat_id_para','<%=son_cat_id %>');"><%=son_cat_name %></a></li>
					       			<%}
					       		}
					       	 %> 
					        </ul>
							<%
								}}
							%>

      </div>
      <div id="RecommendedResults"></div>
      <!--2-->
    </div>
    <div class="areaShoesList">
      <div class="location">
        <div><a href="/shop.html">首页</a> &gt; <a href="/shop_brandlist.html" class="defaultColor">
          <h1>品牌列表</h1>
          </a> </div>
        (共找到<b><%=brandSize %></b>款) </div>
      <div class="pinpainav">
        <ol>
          <li><a href="/shop_brandlist.html" class="current_p">全部</a></li>
          <%
          	for(char c='A';c<='Z';c++){%>
				 <li><a href="/shop_brand.html?pyKey=<%=c %>"><%=c %></a></li>
			<%}%>
        </ol>
       <!--  <%@ include file="/data/brand_content.html"%> -->
      
      </div>
    </div>
    <div class="clear"></div>
    <form action="<%=com_page%>" method="get" name="tongSearchForm">
					<input type="hidden" name="q" id="new_q" value="<%=keyword_b%>" />
					<input type="hidden" name="attr_desc_para" id="attr_desc_para"
						value="<%=cat_desc%>" />
					<input type="hidden" name="orderby_para" id="orderby_para"
						value="<%=orderby%>" />
					<input type="hidden" name="sort_type" id="sort_type"
						value="<%=sort_type%>" />
					<input type="hidden" name="info_state" id="info_state"
						value="<%=info_state %>" />
					<input type="hidden" name="cat_id_para" id="cat_id_para"
						value="<%=cat_id_para%>" />
					<input type="hidden" name="brand_id_para" id="brand_id_para"
						value="<%=brand_id_para%>" />
					<input type="hidden" name="listOrImg" id="listOrImg"
						value="<%=listOrImg%>" />
					<input type="hidden" name="req_url" id="req_url"
						value="<%=com_page %>" />
						
				</form>
			<script>
				function tongyiSearch(orderby,sort_type){
					document.getElementById('orderby_para').value = orderby;
					document.getElementById('sort_type').value = sort_type;
					document.tongSearchForm.submit();
				}
				function state_codeSearch(val){
					document.getElementById('info_state').value = val;
					document.tongSearchForm.submit();
				}
				function updateCatIdBySearch(param_id,param_value){
					document.getElementById(param_id).value = param_value;
					document.getElementById("req_url").value ="/shop_goodslist.html";
					document.tongSearchForm.submit();
				}
				function updateCatIdBySearchSize(param_id,param_value,cat_size){
					document.getElementById(param_id).value = param_value;
					if(cat_size <= 0){
					document.getElementById('new_q').value = '';
					}
					document.tongSearchForm.submit();
				}	
				function dealCatattr(param_id,param_value){
					document.getElementById(param_id).value = document.getElementById(param_id).value + param_value;
					document.tongSearchForm.submit();
				}
				function showList(val)
				{
				  document.getElementById('listOrImg').value = val;
				  document.tongSearchForm.submit();
				}
			</script>
  </div>
	<jsp:include page="/templets/html/shop/footer.jsp"/>
	</body>
</html>
